﻿using System;
using Windows.UI.Xaml;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;

namespace com.IronOne.BoardPACWinAppBO.Comment
{
    public class CommentModel : ObservableObject
    {
        /// <summary>
        ///     The <see cref="SubCategory" /> property's name.
        /// </summary>
        public const string SubCategoryPropertyName = "SubCategory";

        /// <summary>
        ///     The <see cref="MeetingName" /> property's name.
        /// </summary>
        public const string MyPropertyPropertyName = "MeetingName";

        /// <summary>
        ///     The <see cref="CommentSyncedStatus" /> property's name.
        /// </summary>
        public const string CommentSyncedStatusPropertyName = "CommentSyncedStatus";

        private string _commentSyncedStatus;
        private string _meetingName;
        private string _subCategory;
        private RelayCommand<CommentModel> _emailCommentCommand;


        public CommentModel()
        {
            CommentHeadingVisibility = Visibility.Collapsed;
            CommentLeftVisibility = Visibility.Collapsed;
            CommentRightVisibility = Visibility.Collapsed;
            CommentSyncingProgressVisibility = Visibility.Collapsed;
        }

        public static EventHandler EmailCommentOnClick;

        public string CommentId { get; set; }
        public int MeetingId { get; set; }
        public string MainCategory { get; set; }

        /// <summary>
        ///     Sets and gets the SubCategory property.
        ///     Changes to that property's value raise the PropertyChanged event.
        /// </summary>
        public string SubCategory
        {
            get { return _subCategory; }

            set
            {
                if (_subCategory == value)
                {
                    return;
                }

                _subCategory = value;
                RaisePropertyChanged(SubCategoryPropertyName);
            }
        }

        //public string SubCategory { get; set; }
        public string Name { get; set; }
        public int CommentType { get; set; }
        public string Comment { get; set; }
        public string CommentBy { get; set; }
        public DateTime CommentDate { get; set; }
        public string CommentDateString { get; set; }
        public string CommentTypeName { get; set; }
        public string MeetingVenue { get; set; }
        public int CommentCount { get; set; }

        public string MeetingName
        {
            get { return _meetingName; }

            set
            {
                if (_meetingName == value)
                {
                    return;
                }

                _meetingName = value;
                RaisePropertyChanged(MyPropertyPropertyName);
            }
        }

        //public string MeetingName { get; set; }
        public string CommentAlignment { get; set; }
        public Visibility CommentHeadingVisibility { get; set; }
        public Visibility CommentLeftVisibility { get; set; }
        public Visibility CommentRightVisibility { get; set; }
        public string CommentBackgroundColor { get; set; }
        public string CommentArrowPath { get; set; }
        public int MemberId { get; set; }
        public int PaperId { get; set; }
        public DateTime MeetingDate { get; set; }
        public string MeetingDateString { get; set; }
        public string CommentByBackgroundColor { get; set; }

        public string CommentSyncedStatus
        {
            get { return _commentSyncedStatus; }

            set
            {
                if (_commentSyncedStatus == value)
                {
                    return;
                }

                _commentSyncedStatus = value;
                RaisePropertyChanged(() => CommentSyncedStatus);
            }
        }

        public Visibility CommentSyncingProgressVisibility { get; set; }
        public int PendingStatus { get; set; }

        /// <summary>
        /// Gets the EmailCommentCommand.
        /// </summary>
        public RelayCommand<CommentModel> EmailCommentCommand
        {
            get
            {
                return _emailCommentCommand
                    ?? (_emailCommentCommand = new RelayCommand<CommentModel>(
                    (SelectedCommentItem) =>
                    {
                        EmailCommentOnClick(SelectedCommentItem, EventArgs.Empty);
                    }));
            }
        }

        public string EmailBtnBgColor { get; set; }

        public Visibility EmailBtnVisibility { get; set; }
    }

    public class MeetingWiseCommentModel
    {
        public string CommentTypeName { get; set; }
        public string Comment { get; set; }
        public string Name { get; set; }
        public string CommentAlignment { get; set; }
    }
}